home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_084 / ed / getnum.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  1KB  |  65 lines

  1. /*
  2.  * Copyright 1987 Brian Beattie Rights Reserved.
  3.  *
  4.  * Permission to copy and/or distribute granted under the
  5.  * following conditions:
  6.  *
  7.  * 1). No charge may be made other than resonable charges
  8.  *    for reproduction.
  9.  *
  10.  * 2). This notice must remain intact.
  11.  *
  12.  * 3). No further restrictions may be added.
  13.  *
  14.  */
  15. #include <stdio.h>
  16. #include "tools.h"
  17. #include "ed.h"
  18.  
  19. TOKEN    *srchpat;
  20. char    lstsrch;
  21. getnum()
  22. {
  23.     int    num;
  24.     char    c;
  25.  
  26.     while(*inptr == SP || *inptr == HT)
  27.         inptr++;
  28.  
  29.     if(*inptr >= '0' && *inptr <= '9')    /* line number */
  30.     {
  31.         for(num = 0; *inptr >= '0' && *inptr <= '9';)
  32.         {
  33.             num = (num * 10) + *inptr - '0';
  34.             inptr++;
  35.         }
  36.         return ( num > lastln ? ERR : num );
  37.     }
  38.  
  39.     switch(c = *inptr)
  40.     {
  41.     case '.':
  42.         inptr++;
  43.         return (curln);
  44.  
  45.     case '$':
  46.         inptr++;
  47.         return (lastln);
  48.  
  49.     case '/':
  50.     case '?':
  51.         lstsrch = c;
  52.         srchpat = optpat(srchpat);
  53.         if(*inptr == c)
  54.             *inptr++;
  55.         return(find(srchpat,c == '/'?1:0));
  56.  
  57.     case '-':
  58.     case '+':
  59.         return(curln);
  60.  
  61.     default:
  62.         return ( EOF );        /* unknown address */
  63.     }
  64. }
  65.